package shuati;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n;
        int []counter=new int[105];
        int[][] a=new int[10005][25];
        int []result=new int[10005] ;
        int p = 0;
        int maxnum = 0,maxtime = 0;
        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        for(int i = 0;i<n;i++){
            a[i][0]=sc.nextInt();
            a[i][1]=sc.nextInt();
            for(int j = 2;j<=a[i][1]+1;j++){
               a[i][j]=sc.nextInt();
                counter[a[i][j]]++;
                if(counter[a[i][j]]>maxtime){
                    maxtime = counter[a[i][j]];
                    maxnum = a[i][j];
                }
            }
        }
        for(int i = 0;i<n;i++){
            for(int j = 2;j<=a[i][1]+1;j++){
                if(a[i][j] == maxnum){
                    result[p] = a[i][0];
                    p++;
                }
            }
        }
        System.out.println(maxnum);


        sort(result,0,p-1);
        System.out.print( result[0]);
        for(int i = 1;i<p;i++){
            if(result[i] == result[i-1]){
                continue;
            }else{
                System.out.print(" "+result[i]);
            }
        }


    }
    public static void sort(int[] q, int l, int r){
        if(l>=r) return;
        int x=q[l],i=l-1,j=r+1;
        while(i<j){
            do i++;while(q[i]<x);
            do j--;while(q[j]>x);
            int t = q[i];
            if(i<j) swap(q,i,j);
        }
        sort(q,l,j);
        sort(q,j+1,r);
    }
    public static void swap(int[] data, int a, int b) {
        int t = data[a];
        data[a] = data[b];
        data[b] = t;
    }
}